package com.zsck.zsgy.ui.main.fragment.simplecircle

import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.blankj.utilcode.util.LogUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.listener.OnItemClickListener
import com.zsck.zsgy.R
import com.zsck.zsgy.base.BaseFragment
import com.zsck.zsgy.base.BaseViewModel
import com.zsck.zsgy.databinding.FragmentSimpleListBinding
import com.zsck.zsgy.ui.main.fragment.SimpleCircleFragment
import com.zsck.zsgy.ui.main.fragment.simplecircle.adapter.SimpleCircleAdapter

class SimpleListFragment : BaseFragment<SimpleCircleViewModel, FragmentSimpleListBinding>() {
    companion object {
        fun newInstance(type: Int): SimpleListFragment {
            val args = Bundle()
            args.putInt("type", type)
            val fragment = SimpleListFragment()
            fragment.arguments = args
            return fragment
        }

    }

    private var simpleCircleAdapter = SimpleCircleAdapter()
    private var type =2
    override fun initView(savedInstanceState: Bundle?) {

        var type= arguments?.getInt("type")!!
        binding.rcvSimple.isNestedScrollingEnabled = false
        binding.rcvSimple.layoutManager = LinearLayoutManager(mContext)
        binding.rcvSimple.adapter = simpleCircleAdapter
        simpleCircleAdapter.setOnItemClickListener(object : OnItemClickListener {
            override fun onItemClick(adapter: BaseQuickAdapter<*, *>, view: View, position: Int) {

            }
        })

    }


    override fun layoutId(): Int {
        return R.layout.fragment_simple_list
    }

    override fun lazyLoad() {
        super.lazyLoad()
        loadsimpleCircleList()

    }

    override fun initData() {

    }

    private var page = 1

    private fun loadsimpleCircleList() {

        viewModel.simpleCircleList(page, type)
        viewModel.simpleCircleModel.observe(this, {
            simpleCircleAdapter.setList(it?.rows)
            LogUtils.e("loadsimpleCircleList :"+it?.rows?.size)
        })


    }

}